#ifndef PROTOCOL_H
#define PROTOCOL_H

//协议数据单元结构体
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define REGIST_OK "regist ok"
#define REGIST_FAILED_NAMEREPAET "regist failed : name repeat"
#define REGIST_FAILED "regist failed"
#define LOGIN_OK "login ok"
#define LOGIN_FAILED "login failed: maybe pwd wrong or repeat login"

enum ENUM_MSG_TYPE
{
    ENUM_MSG_TYPE_MIN=0,
    ENUM_MSG_TYPE_REGIST_REQUEST,
    ENUM_MSG_TYPE_REGIST_RESPOND,
    ENUM_MSG_TYPE_LOGIN_REQUEST,
    ENUM_MSG_TYPE_LOGIN_RESPONSE,
    ENUM_MSG_TYPE_ALL_ONLINE_USER_REQUEST,
    ENUM_MSG_TYPE_ALL_ONLINE_USER_RESPONSE,
    ENUM_MSG_TYPE_SEARCH_USER_REQUEST,
    ENUM_MSG_TYPE_SEARCH_USER_RESPONSE
};

typedef unsigned int uint;
struct PDU
{
    //协议数据单元长度
    uint uiPDULen;
    //消息类型
    uint uiMsgType;
    //文件名或其他信息数据
    char odata[64];
    //实际消息长度
    uint uiMsgLen;
    //实际消息
    char caMsg[];
};
PDU* mkPDU(uint uiMsgLen);


#endif // PROTOCOL_H
